import os
from os.path import join, getsize

def getdirsize(dir):
    if dir is None or dir == "":
        dir = os.getcwd()
    if os.path.exists(dir):
        size = 0
        for root, dirs, files in os.walk(dir):
            size += sum([getsize(join(root, name)) for name in files])
        print('文件夹大小是 %.3f' % (size), 'B in '+dirpath)
    else:
        print("目录不存在")


if __name__ == '__main__':
    dirpath = input("你想统计的文件夹（不填则默认当前文件所在目录）：")
    getdirsize(dirpath)